// pages/frCollege/frCollege.js
const app = getApp();
var host = app.globalData.host;
var self = null;

Page({
  data: {
    themeColor: '',
    defaultColor: '',
    borderColor: '',
    list: [],
    cnSchoolId: ''
  },
  onLoad: function (options) {
    self = this;
    self.getStyle();
    // self.setData({
    //   cnSchoolId: options.cnSchoolId
    // })
    // wx.request({
    //   url: host + '/lx/search/ukSchools',
    //   data: {
    //     cnSchoolId: self.data.cnSchoolId
    //   },
    //   success: function(res) {
    //     self.setData({
    //       list: res.data.info
    //     })
    //   }
    // })
  },
  getStyle() {
    self.setData({
      themeColor: app.globalData.themeColor,
      defaultColor: app.globalData.defaultColor,
      borderColor: app.globalData.borderColor
    })
  },
  search(e) {
    wx.request({
      url: host + '/lx/search/ukSchools',
      data: {
        // cnSchoolId: self.data.cnSchoolId,
        kw: e.detail.value
      },
      success: function (res) {
        self.setData({
          list: res.data.info
        });
      }
    })
  },
  selectSchool(e) {
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2];
    prevPage.setData({
      ukSchoolId: e.currentTarget.dataset.schoolid,
      ukSchoolName: e.currentTarget.dataset.schoolname
    })
    wx.navigateBack({
      delta: 1
    })
  }
})